//
//  BaseTextFiled.m
//  HouseMarket
//
//  Created by tongj on 2017/8/23.
//  Copyright © 2017年 陶金珂. All rights reserved.
//

#import "BaseTextFiled.h"

@implementation BaseTextFiled

/*
 self.layer.masksToBounds = YES;
 self.layer.cornerRadius = 0;
 self.backgroundColor = [UIColor whiteColor];
 self.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
 self.layer.borderWidth = 3;
 //字体大小
 self.font = [UIFont systemFontOfSize:14];
 //字体颜色
 self.textColor = color333333;
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}
-(void)setUpUI{
    
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 0;
    self.backgroundColor = [UIColor whiteColor];
    self.layer.borderColor = HEXRGB(0xb9d6d2).CGColor;
    self.layer.borderWidth = 3;
}
- (CGRect)textRectForBounds:(CGRect)bounds {
    return CGRectInset( bounds,20, 0);
}
// 控制输入后文本的位置，缩进20
- (CGRect)editingRectForBounds:(CGRect)bounds {
    return CGRectInset( bounds, 20, 0);
}

- (void)setBorderWidth:(CGFloat)borderWidth
{
    if (borderWidth < 0) {
        return;
    }
    self.layer.borderWidth = borderWidth;
}

//边框颜色
- (void)setBorderColor:(UIColor *)borderColor
{
    self.layer.borderColor = borderColor.CGColor;
}

//圆角
- (void)setCornerRadius:(CGFloat)cornerRadius
{
    if (cornerRadius < 0) {
        return;
    }
    self.layer.cornerRadius = cornerRadius;
    self.layer.masksToBounds = cornerRadius > 0;
}

@end
